#ifndef SL808X_H_INCLUDED
#define SL808X_H_INCLUDED

#include <compiler.h>

#define HOST_APP_TX_CMD_MAX_SIZE             (128)
#define HOST_APP_RX_CMD_MAX_SIZE             (1024)

#define HOST_APP_TX_MAX_BUFFER_SIZE				(512)

#define HOST_APP_RX_MAX_BUFFER_SIZE				(512)


typedef enum
{
	HOST_APP_RET_STATUS_ERROR=0,
	HOST_APP_RET_STATUS_OK=1,
	HOST_APP_RET_STATUS_VALID_DATA=2,
	HOST_APP_RET_STATUS_CONTROL_CODE=3,

	HOST_APP_RET_STATUS_MAX

}HOST_APP_RET_STATUS_E;

typedef enum
{
	HOST_APP_DISABLE=0,
	HOST_APP_ENABLE=1
}HOST_APP_STATUS_E;

typedef enum
{
	HOST_APP_CON_TCP_SERVER,
	HOST_APP_CON_UDP_SERVER,
	HOST_APP_CON_UDP_CLIENT,
	HOST_APP_CON_TCP_CLIENT

}HOST_APP_CON_TYPE;


typedef enum
{
	HOST_APP_RX_STATE_START = 0,
	HOST_APP_RX_STATE_CMD_RESP,
	HOST_APP_RX_STATE_ESCAPE_START,
	HOST_APP_RX_STATE_DATA_HANDLE,
	HOST_APP_RX_STATE_BULK_DATA_HANDLE,
	HOST_APP_RX_STATE_HTTP_RESPONSE_DATA_HANDLE,
	HOST_APP_RX_STATE_RAW_DATA_HANDLE,
	HOST_APP_RX_STATE_MAX

}HOST_APP_RX_STATE_E;


typedef enum
{
	HOST_APP_MSG_ID_NONE        = 0,
	HOST_APP_MSG_ID_OK          = 1,
	HOST_APP_MSG_ID_INVALID_INPUT,
	HOST_APP_MSG_ID_ERROR,
	HOST_APP_MSG_ID_ERROR_IP_CONFIG_FAIL,
	HOST_APP_MSG_ID_ERROR_SOCKET_FAIL,
	HOST_APP_MSG_ID_DISCONNECT,
	HOST_APP_MSG_ID_DISASSOCIATION_EVENT,
	HOST_APP_MSG_ID_APP_RESET,
	HOST_APP_MSG_ID_OUT_OF_STBY_ALARM,
	HOST_APP_MSG_ID_OUT_OF_STBY_TIMER,
	HOST_APP_MSG_ID_UNEXPECTED_WARM_BOOT,
	HOST_APP_MSG_ID_OUT_OF_DEEP_SLEEP,
	HOST_APP_MSG_ID_WELCOME_MSG,
	HOST_APP_MSG_ID_STBY_CMD_ECHO,
	HOST_APP_MSG_ID_TCP_CON_DONE,
	HOST_APP_MSG_ID_RESPONSE_TIMEOUT,
	HOST_APP_MSG_ID_BULK_DATA_RX,
	HOST_APP_MSG_ID_DATA_RX,
	HOST_APP_MSG_ID_RAW_DATA_RX,
	HOST_APP_MSG_ID_ESC_CMD_OK,
	HOST_APP_MSG_ID_ESC_CMD_FAIL,
	HOST_APP_MSG_ID_HTTP_RESPONSE_DATA_RX,
	HOST_APP_MSG_ID_MAX

}HOST_APP_MSG_ID_E;


typedef enum
{
	HOST_APP_ESC_CHAR,

}HOST_APP_MSG_INF_E;

#define HOST_APP_LF_CHAR		'\r'

#define RN171_CMD_START			"$$$"
#define RN171_CMD_FTRY			"factory R\r\n"
#define RN171_CMD_RBOT			"reboot\r\n"
#define RN171_CMD_SSID			"set wlan ssid moveR\r\n"
#define RN171_CMD_PASS			"set wlan pass chxg23@gmail.com\r\n"
#define RN171_CMD_JOIN			"set wlan join 1\r\n"
#define RN171_CMD_SAVE			"save\r\n"
#define RN171_CMD_REBOOT		"reboot\r\n"

extern struct usart_module usart_instance;

uint8_t rn171_init( void );
void rn171_data_handle( uint8_t dat);
void wifi_task( void *pvParameters );


#endif